\grid

SYNOPSIS:
\grid(width,height)( Δwidth, Δheight)[initial-X-integer,initial-Y-integer]

For example, the following are all valid commands:

\put(0,0){\grid(95,100)(9.5,10)}
\put(0,0){\grid(100,100)(10,5)[-10,0]}
\put(0,0){\tiny \grid(100,100)(5,5)[0,0]} % the numbers in \tiny font.
\put(50,50){\makebox(0,0){\tiny \grid(20,20)(4,4)}}

The \grid command makes a grid of size width units by height units where vertical lines are drawn at intervals of Δwidth and horizontal lines at intervals of Δheight. The major motivation for this command is that making a grid in the picture initially can be very useful when laying out pictures – it's like having a graph underneath the picture which can be eventually deleted or commented out. Moreover, one might actually want a grid as an object in its own right! Figure 1 (on page 14) presents an example of this command.

The width and height should be divisible by their respective Δ's, otherwise the grid will not be of correct dimensions. The numbers in [ ] at the end are optional. Their absence makes a simple grid with lines. Their presence makes a ``numbered'' grid with integers around the borders where the numbers put have the starting value as specified in [. , .] argument and are incremented by Δwidth and Δheight respectively. If specified, then these starting numbers must be integers. The dimensions are all in units and do not have to be integers, although in most cases one will want integers only. There is an additional constraint when plotting a ``numbered'' grid — the have to be integers, since one cannot easily generate real numbers from within TEX. None of the errors of this kind are caught, hence, if the grid comes out funny, one of the above-mentioned conditions may have been violated.

The \grid command produces a box and thus needs to be \put at the required coordinates. The reference point of the grid is the bottom-left corner and the numbers along the borders, if any, do not affect the reference point. If it is desired to have another reference point, then the whole grid statement may be put in a \makebox(0,0)[..]{...\grid...} kind of construction.